<%@ page language="java" pageEncoding="utf-8" contentType="text/html; charset=utf-8"%>
<%@ include file="../include/taglib.jsp" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head> 
  	<title>餐厅简介</title>
  	<%@ include file="../include/jsCss.jsp" %> 
  	<script type="text/javascript" src="${webUrl}/js/My97DatePicker/WdatePicker.js"></script>
  	<script type="text/javascript" src="${webUrl}/js/provincecity.js"></script>
  </head>
  
  <body>
  	<form action="meal!restaurantSave.html" method="post">
      		餐厅简介
      		<hr/>
      		<table width="100%">
      			<tr>
	      			<td colspan="2">餐厅形象图片(最多可上传3张)</td>
	      		</tr>
	      		<tr>
		      		<td colspan="2">
		      		 	<iframe src="${webUrl}/images!imageUpload.html?width=300&height=400" width="100%" height="250" scrolling="no" frameborder="0" style="border:0px;"></iframe>
		      		</td>
	      		</tr>
	      		 
	      		<tr>
	      			<td>饭店名称：</td>
	      			<td> 
	      				<s:if test="restaurantDto.name != null">
	      					<input type="text" name="restaurantDto.name" value="${restaurantDto.name }"/>
	      				</s:if>
	      				<s:else>
	      					<input type="text" name="restaurantDto.name" value="${user.realName }"/>
	      				</s:else>
	      			</td>
	      		</tr>
	      		<tr>
	      			<td>所在城市：</td>
	      			<td>
	      				<%-- <select name="restaurantDto.province" id="province" onchange="provinceOption(this.value)">
	      					<option value="0">---------</option>
	      					<s:iterator value="areaList">  
	      						<s:if test="code == restaurantDto.province">
	      								<option value="${code }" selected="true">${fullName }</option> 
	      						</s:if>
								<s:else>
									<option value="${code }">${fullName }</option> 
								</s:else>
							</s:iterator>
	      				</select>  --%>
	      				${restaurantDto.province}
	      				<s:if test="restaurantDto.province!=null">
	      					<select id="province" name="restaurantDto.province" onChange="loadCity();">
	      						<s:property value="restaurantDto.province"/>
	      					</select>
	      				</s:if>
	      				<s:else>
	      			 		<select id="province" name="restaurantDto.province" onChange="loadCity();">
	      			 		</select>
	      			 	</s:else>
	      			 	<select id="city" name="city" ></select>
	      				<%-- <select id="city" name="restaurantDto.city" onchange="cityOption(this.value)">
	      					 <option value="0">---------</option>
	      				</select>--%>
	      			 
	      				<%-- <select id="district" name="restaurantDto.district" onchange="districtOption(this.value)">
	      					<option value="0">---------</option>
	      				</select>
	      				<input type="text" id="district" name="district"></input>--%>
	      			 
	      				<%-- <select id="street" name="restaurantDto.street">
	      					<option value="0">---------</option>
	      				</select>
	      				<input type="text" id="street" name="restaurantDto.street"></input>--%>
	      			</td>
	      		</tr>
	      		<tr>
	      			<td>
	      				餐厅地址：
	      			</td>
	      			<td>
	      				<input type="text" name="restaurantDto.address" value="${restaurantDto.address }"/>
	      			</td>
	      		</tr>
	      		<tr>
	      			<td>
	      				餐厅菜系：
	      			</td>
	      			<td>
	      				 <s:iterator value="mealStyleList">
							<input type="checkbox" value="${id }" name="mealList"/> ${name }
						</s:iterator>
						<input type="hidden" name="restaurantDto.mealStyle" id="mealStyle" value="${restaurantDto.mealStyle }">
	      			</td>
	      		</tr>
	      		<tr>
	      			<td>
	      				营业时间：
	      			</td>
	      			<td>
	      				<!--<input type="text" size="10" name="restaurantDto.beginTime" value="${restaurantDto.beginTime }"/> - <input type="text" size="10" name="restaurantDto.endTime" value="${restaurantDto.endTime }"/>-->
	      				<input type="textbox" size="10" onClick="WdatePicker();" name="restaurantDto.beginTime" value="${restaurantDto.beginTime}" onFocus="WdatePicker({startDate:'00:00:00',dateFmt:'HH:mm:ss',alwaysUseStartDate:true})"/>
	      				-
	      				<input type="textbox" size="10" onClick="WdatePicker();" name="restaurantDto.endTime" value="${restaurantDto.endTime}" onFocus="WdatePicker({startDate:'00:00:00',dateFmt:'HH:mm:ss',alwaysUseStartDate:true})"/>
	      			</td> 
	      		</tr>
	      		<tr>
	      			<td>订餐电话：</td>
	      			<td>
	      				<input type="text" name="restaurantDto.moilbe" value="${restaurantDto.moilbe }"/> 
	      				<input type="checkbox" onclick="selectSchedule2(this)" id="selectSchedule" <s:if test="restaurantDto.isPreordain == true">checked='checked'</s:if>/>不支持预定
	      				<input type="hidden" name="restaurantDto.isPreordain" value="false" id="isSchedule"/>
	      			</td>
	      		
	      		</tr>
	      		<tr>
	      			<td>联系人：</td>
	      			<td>
	      				<input type="text" name="restaurantDto.linkman" value="${restaurantDto.linkman}"/>
	      			</td>
	      		</tr>
	      		<tr>
	      			<td>餐厅简介：</td>
	      			<td>
	      				<textarea rows="5" cols="25" name="explanation">${restaurantDto.explanation}</textarea>
	      			</td>
	      		</tr>
	      		
	      		<tr>
	      			<td><input type="submit" value="确定" onclick="return mealStyleSelect();"> </td>
	      		</tr>
      		</table>
      	</form>
    <script type="text/javascript">
  		function provinceOption(v) { 
  			 $("#city").html("<option value='0'>---------</option>");
			 $("#district").html("<option value='0'>---------</option>");
			 $("#street").html("<option value='0'>---------</option>");
  			$.ajax({type : "post",
					url : "meal!queryArea.html",
					data : {
						parentCode : v
					},
					success : function(result) { 
						 var res = eval("(" + result + ")");
						
						 for (var i = 0; i < res.length; i++) {
						 	if (res[i].code == '${restaurantDto.city }') {
						 		$("#city").append("<option value='"+res[i].code+"' selected='selected'>"+res[i].fullName+"</option>"); 
						 	} else {
						 	 	$("#city").append("<option value='"+res[i].code+"'>"+res[i].fullName+"</option>"); 
						 	 }
						 }
					},
					error : function(result) {
						alert("数据读取失败！");
					}
			});
  		}
  		
  		function cityOption(v) {
  			$("#district").html("<option value='0'>---------</option>");
			$("#street").html("<option value='0'>---------</option>");
  			$.ajax({type : "post",
					url : "meal!queryArea.html",
					data : {
						parentCode : v
					},
					success : function(result) { 
						 var res = eval("(" + result + ")");
						 
						 for (var i = 0; i < res.length; i++) {
						 	if (res[i].code == '${restaurantDto.district }') {
						 		$("#district").append("<option value='"+res[i].code+"' selected='selected'>"+res[i].fullName+"</option>"); 
						 	} else {
						 	    $("#district").append("<option value='"+res[i].code+"'>"+res[i].fullName+"</option>"); 
						 	} 
						 }
					},
					error : function(result) {
						alert("数据读取失败！");
					}
			});
  		}
  		
  		function districtOption(v) {
  			$.ajax({type : "post",
					url : "meal!queryArea.html",
					data : {
						parentCode : v
					},
					success : function(result) { 
						 var res = eval("(" + result + ")");
						 $("#street").html("<option value='0'>---------</option>");
						 for (var i = 0; i < res.length; i++) {
						 	if (res[i].code == '${restaurantDto.street }') {
						 		$("#street").append("<option value='"+res[i].code+"' selected='selected'>"+res[i].fullName+"</option>"); 
						 	} else {
						 	 	$("#street").append("<option value='"+res[i].code+"'>"+res[i].fullName+"</option>"); 
							}
						 }
					},
					error : function(result) {
						alert("数据读取失败！");
					}
			});
  		}
  		
  		function selectSchedule2(t) {
  			if (t.checked == true) {
  				$("#isSchedule").val('true');
  			} else {
  				$("#isSchedule").val('false');
  			}
  		}
  		
  		function mealStyleSelect() {
  			var v = "";
  			$("input[name='mealList']").each(function(i,item){ 
  				if (item.checked == true) {
  					v += item.value + ",";
  				}
  			});
  			
  			$("#mealStyle").val(v.substring(0, v.length-1));
  			
  			return true;
  		} 
  		
  		function provinceLoad() { 
		  		if ('${restaurantDto.province}' != '' && '${restaurantDto.province}' != 0 && '${restaurantDto.province}' != null) {
		  			provinceOption('${restaurantDto.province}');
		  			 
		  		} 
		  		if ('${restaurantDto.city}' != '' && '${restaurantDto.city}' != 0 && '${restaurantDto.city}' != null) {
		  			 cityOption('${restaurantDto.city}');
		  		}
		  		  
		  		if ('${restaurantDto.district}' != '' && '${restaurantDto.district}' != 0 && '${restaurantDto.district}' != null) {
		  			districtOption('${restaurantDto.district}');
		  		} 
	  		$("input[name='mealList']").each(function(i,item){
  				 if ('${restaurantDto.mealStyle}'.indexOf(item.value) > -1) {
  				 	item.checked = true;
  				 }
  			}); 
  		}
  		provinceLoad();
  	</script>
  </body>
</html>
